package com.pangus.toolkits.files.operation;

import com.pangus.toolkits.files.FSContext;
import com.pangus.toolkits.files.FSCredentials;
import com.pangus.toolkits.files.utils.AuthUtil;
import okhttp3.Request;

import java.util.Objects;

/**
 * @author yingheng chen
 * @description
 * @date 2019/11/30
 */
public class BaseOperation {
     protected FSContext context;

    public BaseOperation(FSContext context) {
        this.context = context;
    }

    protected Request.Builder getBaseRequestBuilder() {
         Objects.requireNonNull(context, "context not null");
        Request.Builder builder = new Request.Builder();
        FSCredentials credentials = context.getCredentials();

        return builder.header("Authorization", AuthUtil.JWT_TOKEN + AuthUtil.encode(credentials));
     }


}
